package router

import (
	_type "gitee.com/yangguoliang001/go-gin-vue3/type"
	"github.com/gin-gonic/gin"
	"github.com/pkg/errors"
	"go.uber.org/zap"
)

func CollectRoute(r *gin.Engine, logger *zap.Logger) (*gin.Engine, error) {
	if logger == nil {
		logger.Error("logger is required")
		return r, errors.New("logger is required")
	}

	resource := new(_type.Resource)
	resource.R = r
	resource.Logger = logger
	setSwaggerRouter(resource)
	setInstallRouter(resource)
	SetApiRouter(resource)

	return r, nil
}
